import java.util.Scanner;

public class ControlPanel {
    private static final String PASSWORD = "1234"; // 设置的密码
    private static final int MAX_ATTEMPTS = 3; // 最大尝试次数
    private static final int LOCK_TIME = 120; // 锁定时间，单位：秒

    public static void main(String[] args) {
        int attempts = 0; // 记录尝试次数
        long lastAttemptTime = 0; // 记录上次尝试时间

        Scanner scanner = new Scanner(System.in);

        while (true) {
            if (System.currentTimeMillis() - lastAttemptTime > LOCK_TIME * 1000) {
                System.out.println("请输入密码：");
                String input = scanner.next();

                if (input.length() == PASSWORD.length()) {
                    attempts++;

                    if (input.equals(PASSWORD)) {
                        System.out.println("密码正确，进入系统功能选择状态。");
                        break;
                    } else {
                        System.out.println("密码错误。");

                        if (attempts >= MAX_ATTEMPTS) {
                            System.out.println("密码错误次数超过" + MAX_ATTEMPTS + "次，控制面板已被锁定。");
                            lastAttemptTime = System.currentTimeMillis();
                            attempts = 0;
                        }
                    }
                } else {
                    System.out.println("请输入4位密码。");
                }
            } else {
                long remainingTime = LOCK_TIME - (System.currentTimeMillis() - lastAttemptTime) / 1000;
                System.out.println("控制面板已被锁定，请" + remainingTime + "秒后再尝试。");
            }
        }
    }
}